/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.kmcsoft.goldshop.model.master;

import com.kmcsoft.demography.entity.Address;
import com.kmcsoft.emaster.entity.Employee;
import com.kmcsoft.emaster.entity.TrackableEntity;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.jdo.annotations.FetchGroup;
import javax.jdo.annotations.FetchGroups;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;

/**
 *
 * @author kmcsoft02
 */
@PersistenceCapable(detachable = "true", table = "shop")
@FetchGroups(value = {
    @FetchGroup(name = "detach_Shop_All", members = {
        @Persistent(name = "booths"),
        @Persistent(name = "address"),
        @Persistent(name = "empls")}),
    @FetchGroup(name = "detach_Shop_Booth", members = {
        @Persistent(name = "booths")}),
    @FetchGroup(name = "detach_Shop_Address", members = {
        @Persistent(name = "address")}),
    @FetchGroup(name = "detach_Shop_Employee", members = {
        @Persistent(name = "empls")})
})
public class Shop extends TrackableEntity {

    @Persistent
    private String name;
    @Persistent
    private Address address;
    @Persistent
    private String note;
    @Persistent
    private Set<Employee> empls;
    @Persistent
    private List<Booth> booths;
    @Persistent
    private int empNumber;
    @Persistent
    private String picture;

    public Shop() {
        address = new Address();
        picture = new String();
        empls = new HashSet<Employee>();
        booths = new ArrayList<Booth>();
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Address getAddress() {
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public String getNote() {
        return note;
    }

    public void setNote(String note) {
        this.note = note;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    public Set<Employee> getEmpls() {
        return empls;
    }

    public void setEmpls(Set<Employee> empls) {
        this.empNumber = empls.size();
        this.empls = empls;
    }
    public void addEmpls(Set<Employee> empls) {
        this.empls.addAll(empls);
        this.empNumber=this.empls.size();
    }
    public void addEmpl(Employee employee) {
        this.empls.add(employee);
        this.empNumber=this.empls.size();
    }
    public void removeEmpl(Employee employee) {
        this.empls.remove(employee);
        this.empNumber=this.empls.size();
    }

    public int getEmpNumber() {
        return empNumber;
    }

    public List<Booth> getBooths() {
        return booths;
    }

    public void setBooths(List<Booth> booths) {
        this.booths = booths;
    }

    public void addBooth(Booth booth) {
        booths.add(booth);
    }
    public void removeBooth(Booth booth) {
        booths.remove(booth);
    }
}
